# serializers.py

from rest_framework import serializers
from .models import Appointment
from appointment_slot.models import AppointmentSlot
from doctor.models import Doctor
from patient.models import Patient


class AppointmentSlotSerializer(serializers.ModelSerializer):
    class Meta:
        model = AppointmentSlot
        fields = ['id', 'doctor', 'date', 'slot_number', 'available']


class AppointmentSerializer(serializers.ModelSerializer):
    patient_id = serializers.StringRelatedField()  # Assuming Patient model has a __str__ method or username
    doctor_id = serializers.StringRelatedField()
    slot_number = serializers.IntegerField()
    appointment_date = serializers.DateField()

    class Meta:
        model = Appointment
        fields = ['id', 'patient_id', 'doctor_id', 'appointment_date', 'slot_number', 'department', 'remarks', 'status',
                  'created_at', 'updated_at']
